package com.newenergy.wisehome.data.bean;

import android.os.Parcel;
import android.os.Parcelable;

import com.j256.ormlite.field.DatabaseField;
import com.j256.ormlite.table.DatabaseTable;

/**
 * Created by kyx on 2018/4/24.
 * 设备种类的实体类
 */

@DatabaseTable(tableName = "tb_devicecategory")
public class DeviceCategory implements Parcelable {
    @DatabaseField(generatedId = true)
    private int id;
    @DatabaseField(columnName = "uuid")
    private String uuid;
    @DatabaseField(columnName = "blDid")
    private String blDid = "";
    @DatabaseField(columnName = "familyId")
    private String familyId;
    @DatabaseField(columnName = "category")
    private int category;
    @DatabaseField(columnName = "groupId")
    private String groupId;
    @DatabaseField(columnName = "name")
    private String name;
    @DatabaseField(columnName = "pingyinName")
    private String pingyinName;
    @DatabaseField(columnName = "isChecked")
    private boolean isChecked = false;
    @DatabaseField(columnName = "icName")
    private String icName = "icon_bedroom";
    //设备唯一的id
    @DatabaseField(columnName = "deviceId")
    private String deviceId = "000000000000";
    //存储的设备类型，厂家以及型号信息
    @DatabaseField(columnName = "model")
    private String model = "00000000";

    @DatabaseField(columnName = "ld")
    private int ld = 127;

    @DatabaseField(columnName = "sw")
    private int sw = 127;

    public DeviceCategory() {

    }

    public DeviceCategory(String uuid, String familyId, int category, String groupId, String name, String pingyinName, String icName) {
        this.uuid = uuid;
        this.familyId = familyId;
        this.category = category;
        this.name = name;
        this.groupId = groupId;
        this.pingyinName = pingyinName;
        this.icName = icName;
    }


    public DeviceCategory(String familyId, int category, String groupId, String name, String icName, String deviceId, String model) {
        this.familyId = familyId;
        this.category = category;
        this.groupId = groupId;
        this.name = name;
        this.icName = icName;
        this.deviceId = deviceId;
        this.model = model;
    }

    public String getId() {
        return familyId;
    }

    public String getUuid() {
        return uuid;
    }

    public String getFamilyId() {
        return familyId;
    }

    public void setFamilyId(String familyId) {
        this.familyId = familyId;
    }

    public int getCategory() {
        return category;
    }

    public void setCategory(int category) {
        this.category = category;
    }

    public String getGroupId() {
        return groupId;
    }

    public void setGroupId(String groupId) {
        this.groupId = groupId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPingyinName() {
        return pingyinName;
    }

    public void setPingyinName(String pingyinName) {
        this.pingyinName = pingyinName;
    }

    public boolean isChecked() {
        return isChecked;
    }

    public void setChecked(boolean checked) {
        isChecked = checked;
    }

    public String getIcName() {
        return icName;
    }

    public void setIcName(String icName) {
        this.icName = icName;
    }

    public String getDeviceId() {
        return deviceId;
    }

    public void setDeviceId(String deviceId) {
        this.deviceId = deviceId;
    }

    public String getModel() {
        return model;
    }

    public void setModel(String model) {
        this.model = model;
    }

    public int getLd() {
        return ld;
    }

    public void setLd(int ld) {
        this.ld = ld;
    }

    public int getSw() {
        return sw;
    }

    public void setSw(int sw) {
        this.sw = sw;
    }

    public String getBlDid() {
        return blDid;
    }

    public void setBlDid(String blDid) {
        this.blDid = blDid;
    }
    @Override
    public String toString() {
        return "DeviceCategory{" +
                "id=" + id +
                ", uuid='" + uuid + '\'' +
                ", blDid='" + blDid + '\'' +
                ", familyId='" + familyId + '\'' +
                ", category=" + category +
                ", groupId='" + groupId + '\'' +
                ", name='" + name + '\'' +
                ", pingyinName='" + pingyinName + '\'' +
                ", isChecked=" + isChecked +
                ", icName='" + icName + '\'' +
                ", deviceId='" + deviceId + '\'' +
                ", model='" + model + '\'' +
                ", ld=" + ld +
                ", sw=" + sw +
                '}';
    }

    public String toQRContent() {
        return groupId + "&" + name + "&" + category + "&" + deviceId;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(this.id);
        dest.writeString(this.uuid);
        dest.writeString(this.familyId);
        dest.writeInt(this.category);
        dest.writeString(this.groupId);
        dest.writeString(this.name);
        dest.writeString(this.pingyinName);
        dest.writeByte(this.isChecked ? (byte) 1 : (byte) 0);
        dest.writeString(this.icName);
        dest.writeString(this.deviceId);
        dest.writeString(this.model);
        dest.writeInt(this.ld);
        dest.writeInt(this.sw);

    }

    protected DeviceCategory(Parcel in) {
        this.id = in.readInt();
        this.uuid = in.readString();
        this.familyId = in.readString();
        this.category = in.readInt();
        this.groupId = in.readString();
        this.name = in.readString();
        this.pingyinName = in.readString();
        this.isChecked = in.readByte() != 0;
        this.icName = in.readString();
        this.deviceId = in.readString();
        this.model = in.readString();
        this.ld = in.readInt();
        this.sw = in.readInt();
    }

    public static final Parcelable.Creator<DeviceCategory> CREATOR = new Parcelable.Creator<DeviceCategory>() {
        @Override
        public DeviceCategory createFromParcel(Parcel source) {
            return new DeviceCategory(source);
        }

        @Override
        public DeviceCategory[] newArray(int size) {
            return new DeviceCategory[size];
        }
    };
}
